' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.28.02.27]) on 2023.08.30 at 01:06 (Coordinated Universal Time)
' An original BASIC Anywhere Machine program by Charlie Veniot

screen _newimage(640,640,12)
_alert("click and hold, or touch and hold, anywhere on the screen, while dragging a short distance and see what happens.  Try swiping and circular motions.  Click/tap and release.  Multiple quick clicks/taps and release.")
_alert("Refresh this web page to start a new drawing.  Before closing this dialog to start drawing, resize this browser window if your device will let you, to alter the x/y ratio of the canvas.")
_delay 0.125

type tObject 
 exists%
 x%
 y%
 c%
end type

max% = 640
sx = 640
sy = sx * _windowHeight / _windowWidth

dim g1_object(1 to max%) as tObject

screen _newimage(sx,sy,12)

do
    'cls
    for i = 1 to max%
	   if g1_object(i).exists% = TRUE then
		  if g1_object(i).x% = g1_object(i).y% then
		    g1_object(i).x% -= 1
		    g1_object(i).y% -= 1
        elseif g1_object(i).x% > g1_object(i).y% then
		    g1_object(i).y% -= cint(g1_object(i).y%/g1_object(i).x%)
		    g1_object(i).x% -= 1
		  else
		    g1_object(i).x% -= cint(g1_object(i).x%/g1_object(i).y%)
		    g1_object(i).y% -= 1
		  end if
		  if (g1_object(i).x% <= (-sx)) OR (g1_object(i).y% <= (-sy)) then
		    g1_object(i).exists% = FALSE
		  elseif (g1_object(i).x% >= 0) AND (g1_object(i).y% >= 0) then
		    pset (g1_object(i).x%, g1_object(i).y%), g1_object(i).c%
          pset (sx-1-g1_object(i).x%, g1_object(i).y%), g1_object(i).c%
          pset (g1_object(i).x%, sy-1-g1_object(i).y%), g1_object(i).c%
          pset (sx-1-g1_object(i).x%, sy-1-g1_object(i).y%), g1_object(i).c%
		  end if
		end if
	 next i
getmouse x%, y%, w%, b%
if x% >= 0 and x% < sx and y% >= 0 and y% < sy and b% = TRUE then
  bDone = FALSE
  i = 1
  do

    if g1_object(i).exists% = FALSE then
	   g1_object(i).exists% = TRUE : g1_object(i).x% = x% : g1_object(i).y% = y% : g1_object(i).c% = (int(rnd*16)) : pset (x%, y%), g1_object(i).c% :  bDone = TRUE
		pset (sx-1-x%, y%), g1_object(i).c%
		pset (x%, sy-1-y%), g1_object(i).c%
		pset (sx-1-x%, sy-1-y%), g1_object(i).c%
	 end if
    i = i + 1
  loop until ( i > max% ) OR (bDone = TRUE)
end if
  _delay 0.01
loop